class Solution {
    public int getMaxLen(int[] nums) {
        //1. 创建dp表
        //2. 初始化
        //3. 填表
        //4. 返回值
        int n = nums.length;
        int[] f = new int[n+1];
        int[] g = new int[n+1];
        f[0] = g[0] = 0;
        int ret = 0;
        for(int i = 1; i <= n; i++) {
            if(nums[i-1] > 0) {
                f[i] = f[i-1] + 1;
                if(g[i-1] != 0) {
                    g[i] = g[i-1] + 1;
                }
            }else if(nums[i-1] < 0){
                if(g[i-1] != 0) {
                    f[i] = g[i-1] + 1;
                }
                g[i] = f[i-1] + 1;
            }
            ret = Math.max(ret, f[i]);
        }
        return ret;
    }
}